<template>
  <el-dialog :title="type === '1' ? '新增' : '修改'" :visible.sync="dialogFormVisible">
    <el-form :model="form">
      <el-form-item label="代理等级" :label-width="formLabelWidth">
        <el-input v-model="form.level_int" autocomplete="off" type="Number" />
      </el-form-item>
      <el-form-item label="代理等级名称" :label-width="formLabelWidth">
        <el-input v-model="form.level_name" autocomplete="off" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="uploadNewInfo">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { operationBrandLevel } from '@/api/brand'
export default {
  data() {
    return {
      type: '1',
      dialogFormVisible: false,
      formLabelWidth: '100px',
      form: {
        level_name: '',
        level_int: '',
        brand_id: this.$store.state.user.brand_id,
        up_level_int: [],
        down_level_int: []
      }
    }
  },
  methods: {
    uploadNewInfo() {
      const data = {
        type: this.type,
        pro: this.form
      }
      operationBrandLevel(data).then(res => {
        console.log(res)
        if (res.code === 200) {
          this.$message.success('信息提交成功！')
          this.dialogFormVisible = false
          this.form = {
            level_name: '',
            level_int: '',
            brand_id: this.$store.state.user.brand_id,
            up_level_int: [],
            down_level_int: []
          }
          this.$emit('reloadFun')
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
